package model;

import buffer.ConstantSource;
import buffer.Source;

/**
 * The {@link Constant} class always provides the value it was created with on the get()
 * operation on its {@link Source}).
 */
public class Constant<T> implements HasSource<T>{
	
	private final ConstantSource<T> source;

	/**
	 * Constructor of {@link Constant}.
	 * @param value is the value that each output buffer of this instance provides on the get() operation.
	 */
	public Constant(final T value) {
		this.source = new ConstantSource<T>(value);
	}

	@Override
	public Source<T> getSource() {
		return this.source;
	}

	@Override
	public void accept(final HasSourceVisitor<T> visitor) {
		visitor.visit(this);
	}
}
